#include "csapp.h"



int main(int argc, char **argv) 

{

    int clientfd, port;

    char *host, buf[MAXLINE];

    rio_t rio;



    if (argc != 3) {

    fprintf(stderr, "usage: %s <host> <port>\n", argv[0]);

    exit(0);

    }

    host = argv[1];

    port = atoi(argv[2]);



    clientfd = Open_clientfd(host, port);

    Rio_readinitb(&rio, clientfd);



    while (Fgets(buf, MAXLINE, stdin) != NULL) {

    

    time_t t;

    struct tm * lt;

    size_t n; 

    printf("\n客户端IP：127.0.0.1\n");

    printf("服务器实现者学号：20175312\n");

    

    time (&t);//获取Unix时间戳

    lt = localtime (&t);//转为时间结构

    printf ("当前时间为：%d/%d/%d %d:%d:%d\n",lt->tm_year+1900, lt->tm_mon+1, lt->tm_mday, lt->tm_hour, lt->tm_min, lt->tm_sec);//输出结果。注意月份取值区间为[0,11]，所以要+1;年份的修改。

    Rio_writen(clientfd, buf, strlen(buf));

    Rio_readlineb(&rio, buf, MAXLINE);

    Fputs(buf, stdout);

    }

    Close(clientfd); //line:netp:echoclient:close

    exit(0);

}